package com.jic.market.controller.manage;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.entity.PromotionTemplate;
import com.jic.market.request.manager.template.TemplateDeleteRequest;
import com.jic.market.request.manager.template.TemplateEditRequest;
import com.jic.market.request.manager.template.TemplatePageQueryRequest;
import com.jic.market.service.PromotionTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yinhaijun
 * @date: 2020/3/12
 */
@Api(tags = {"模板管理"})
@RestController
@RequestMapping("/template")
public class PromotionTemplateController {

    @Autowired
    private PromotionTemplateService promotionTemplateService;

    @ApiOperation(value = "分页查询")
    @PostMapping("queryPage")
    public RestResult<PageResult<PromotionTemplate>> queryPage(@RequestBody TemplatePageQueryRequest request) {
        return promotionTemplateService.queryPage(request);
    }

    @ApiOperation(value = "编辑")
    @PostMapping("edit")
    public RestResult<Long> edit(@RequestBody TemplateEditRequest request) {
        return promotionTemplateService.edit(request);
    }

    @ApiOperation(value = "删除")
    @PostMapping("delete")
    public RestResult<Long> delete(@RequestBody TemplateDeleteRequest request) {
        return promotionTemplateService.delete(request);
    }

}
